import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-03-02
 * Time: 19:36
 */

public class ListFor {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        //list 列表
        //vcctor 矢量
        //Linked List 链表

        //List 接口实现子类 还有 Vector LinkedList 运行结果完全相同
        //List list = new ArrayList();
        //List list = new Vector();
        List list = new LinkedList();
        list.add("jack");
        list.add("tom");
        list.add("鱼香肉丝");
        list.add("北京烤鸭");

        System.out.println("--------------迭代器----------------");
        //遍历
        //1.迭代器
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object obj =  iterator.next();
            System.out.println(obj);
        }

        System.out.println("--------------增强For----------------");

        //2.增强for
        for (Object o :list) {
            System.out.println(o);
        }

        System.out.println("--------------普通for----------------");

        for (int i = 0; i < list.size(); i++) {
            //当成一个对象 一个数组来取
            System.out.println("对象= " + list.get(i));
        }

    }
}
